<template>
	<view>
		<u-form :model="form" ref="uForm" label-position="top">
			<u-form-item label="手机号" prop="account">
				<u-input v-model="form.account" placeholder="请输入手机号" />
			</u-form-item>
			<u-form-item label="密码" prop="password">
				<u-input type="password" v-model="form.password" placeholder="请输入密码" />
			</u-form-item>
		</u-form>
		<view class="mt152 pl40 pr40">
			<u-button @click="submit" type="primary">登录</u-button>
			<view class="text-center mt46 register flex row-between">
				<text @click="$jump('/pages/login/ForgetPassword/ForgetPassword')">忘记密码</text>
				<text @click="$jump('/pages/register/register')">立即注册</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "passwdLogin",
		data() {
			return {
				//form表单
				form: {
					account: '',
					password: '',
				},
			};
		},
		methods: {
			async submit() {
				if (!this.form.account) {
					return this.$msg('手机号不能为空')
				}
				if (!this.form.password) {
					return this.$msg('密码不能为空')
				}
				this.$api.login(this.form).then(res => {
					this.$msg(res.msg)
					uni.setStorageSync('userInfo', res.data.userinfo)
					uni.setStorageSync('token', res.data.userinfo.token)
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/home/home'
						})
					}, 500)
				})
			}
		}
	}
</script>

<style lang="scss">
	.captcha,
	.register {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: bold;
		text-decoration: underline;
		color: #1385FF;
	}

	.register {
		color: #6D788B;
	}
</style>
